<extend name="_top"/>


<block name="body">
<div class="aw-register-box">
	<h1>欢迎您</h1>
	<h2>在这里创建您的顽瞳账户</h2>
	<div class="mod-body">
		<if condition="$step eq 'start'">
			<form action="{:U('register')}" method="post">
				<input id="name" type="hidden" name="role" value="{$role_list[0]['id']}">
				<ul class="tab-content">
					<li class="alert alert-danger hide error_message text-left">
						<i class="icon icon-delete"></i> <em></em>
					</li>
					
					<volist name="regSwitch" id="regSwitch">
						<switch name="regSwitch">
							<case value="username">
								<li class="tab-pane  <if condition='$key eq 0'>active in</if>" id="username_reg">
									
										<div class="form-group">
											<label for="username" class=".sr-only col-xs-12" style="display: none"></label>
											<input type="text" id="username" onblur="setNickname(this);" class="form-control form_check" check-type="Username" check-url="{:U('ucenter/member/checkAccount')}" placeholder="请输入用户名" value="" name="username">
											<input type="hidden" name="reg_type" value="username">
										</div>
									
								</li>
							</case>
							<case value="email">
								<li class="tab-pane <if condition='$key eq 0'>active in</if>" id="email_reg">
									
										<div class="form-group">
											<label for="username" class=".sr-only col-xs-12" style="display: none"></label>
											<input type="text" id="email" class="form-control form_check" check-type="UserEmail" check-url="{:U('ucenter/member/checkAccount')}" <if condition='$key neq 0'>disabled="disabled"</if> placeholder="请输入邮箱" value="" name="username">
											<input type="hidden" name="reg_type" value="email" <if condition='$key neq 0'>disabled="disabled"</if>>
										</div>

										<php>if(modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 2){</php>
										<div class="form-group">
											<input type="text" class="form-control pull-left" placeholder="验证码" <if condition='$key neq 0'>disabled="disabled"</if> name="reg_verify" style="width: 130px">
											<a class="lh32 btn btn-primary" data-role="getVerify" style="margin-left: 10px">验证邮箱</a>
											<div class="clearfix"></div>
										</div>
										<php>}</php>
									
								</li>
							</case>
							<case value="mobile">
								<li class="tab-pane <if condition='$key eq 0'>active in</if>" id="mobile_reg">
									
					
										<div class="form-group">
											<label for="username" class=".sr-only col-xs-12" style="display: none"></label>
					
											<input type="text" id="mobile" class="form-control form_check" check-type="UserMobile" check-url="{:U('ucenter/member/checkAccount')}" <if condition='$key neq 0'>disabled="disabled"</if> placeholder="请输入手机号" errormsg="请填写手机号" value="" name="username">
					
											<input type="hidden" name="reg_type" value="mobile" <if condition='$key neq 0'>disabled="disabled"</if>>
					
										</div>
					
										<php>if(modC('MOBILE_VERIFY_TYPE', 0, 'USERCONFIG') == 1){</php>
					
										<div class="form-group">
											<input type="text" class="form-control pull-left" placeholder="验证码" name="reg_verify" <if condition='$key neq 0'>disabled="disabled"</if> style="width: 130px">
											<a class="btn btn-primary" data-role="getVerify" style="margin-left: 10px">验证手机</a>
										</div>
										<php>}</php>
								</li>
							</case>
						</switch>
					</volist>
					<li>
						<label for="nickname" class=".sr-only col-xs-12" style="display: none"></label>
						<input type="text" id="nickname" class="form-control form_check" check-type="Nickname" check-url="{:U('ucenter/member/checkNickname')}" placeholder="请输入昵称" value="" name="nickname">
			
					</li>
					<li>
						<input type="password" id="inputPassword" class="form-control" check-length="6,30" placeholder="请输入密码" name="password">
					</li>
			
					<if condition="check_verify_open('reg')">
						<li>
							<label for="verifyCode" class=".sr-only col-xs-12" style="display: none"></label>
							<div class="col-xs-5" style="padding: 0px;">
								<input type="text" id="verifyCode" class="form-control" placeholder="验证码" errormsg="请填写正确的验证码" nullmsg="请填写验证码" datatype="*5-5" name="verify">
							</div>
							<div class="col-xs-7 "style="padding: 0px;">
								<img class="verifyimg reloadverify img-responsive pull-right" alt="点击切换" src="{:U('verify')}" style="cursor:pointer;height: 40px;">
							</div>
							<div class="col-xs-12 Validform_checktip text-warning lg_lf_fm_tip"></div>
						</li>
					</if>
					<li class="last">
						<a href="{:U('Ucenter/Member/login')}" class="pull-right">已有账号?</a>
					</li>
					<li class="clearfix">
						<button class="btn btn-large btn-primary" type="submit" style="width: 320px;">注册</button>
					</li>
				</ul>
			</form>
		</if>
		<if condition="$step neq 'start' and $step neq 'finish'">
			{:W('RegStep/view')}
		</if>
		<if condition="$step eq 'finish'">
			<div class="col-xs-6">
			<dl>
				<dt>现在你可以：</dt>
				<dd>1.先去<a href="{:U('Ucenter/Config/index')}" title="个人信息">完善个人信息</a></dd>
				<dd>2.去<a href="{:U('home/Index/index')}" title="顽瞳首页">首页</a>看看</dd>
				<dd>3.去<a href="{:U('Group/Index/index')}" title="树丛广场">树丛</a>瞧瞧</dd>
				<dd>4.去了解<a href="{:U('News/Index/index')}" title="教育资讯">资讯</a></dd>
				<dd>5.发表话题和评论</dd>
				<dd class="last">更多由您选择</dd>
			</dl>
			</div>
			<div class="col-xs-6">
				<img src="__THEME_PUBLIC__/images/logom.png" class="pull-right" />
			</div>
			<a class="btn btn-large btn-primary" href="{:U('home/index/index')}" style="width: 320px;margin:20px 0;background: #5ac215;">开始体验</a>
			<div class="clearfix"></div>
		</if>
		
	</div>
	<div class="mod-footer">
		<ul id="reg_nav">
			<php>if(check_reg_type('username')){</php>
			<li <if condition="$regSwitch[0] eq 'username'">class="active"</if>><a href="#username_reg" data-toggle="tab">{:L('_REGISTER_USERNAME_')}</a></li>
			<php>}</php>
			<php>if(check_reg_type('email')){</php>
			<li <if condition="$regSwitch[0] eq 'email'">class="active"</if>><a href="#email_reg" data-toggle="tab">{:L('_REGISTER_EMAIL_')}</a></li>
			<php>}</php>
			<php>if(check_reg_type('mobile')){</php>
			<li <if condition="$regSwitch[0] eq 'mobile'">class="active"</if>><a href="#mobile_reg" data-toggle="tab">{:L('_REGISTER_PHONE_')}</a></li>
			<php>}</php>
		</ul>
	</div>
</div>

    
</block>

<block name="script">
    <script type="text/javascript">
        var step="{$step}";
        if (MID == 0&&step=='start') {
            $(document)
                    .ajaxStart(function () {
                        $("button:submit").addClass("log-in").attr("disabled", true);
                    })
                    .ajaxStop(function () {
                        $("button:submit").removeClass("log-in").attr("disabled", false);
                    });
            $("form").submit(function () {
                toast.showLoading();
                var self = $(this);
                $.post(self.attr("action"), self.serialize(), success, "json");
                return false;

                function success(data) {
                    if (data.status) {
                        //toast.success(data.info, '温馨提示');
                        setTimeout(function () {
                            window.location.href = data.url
                        }, 10);
                    } else {
                        toast.error(data.info, '温馨提示');
                        //self.find(".Validform_checktip").text(data.info);
                        //刷新验证码
                        $(".reloadverify").click();
                    }
                    toast.hideLoading();
                }
            });

            function change_show(obj) {
                if ($(obj).text().trim() == 'show') {
                    $(obj).html('hide');
                    $(obj).parents('.password_block').find('input').attr('type', 'text');
                } else {
                    $(obj).html('show');
                    $(obj).parents('.password_block').find('input').attr('type', 'password');
                }
            }


            function setNickname(obj) {
                var text = jQuery.trim($(obj).val());
                if (text != null && text != '') {
                    $('#nickname').val(text);
                }
            }

            $(function () {
                var verifyimg = $(".verifyimg").attr("src");
                $(".reloadverify").click(function () {
                    if (verifyimg.indexOf('?') > 0) {
                        $(".verifyimg").attr("src", verifyimg + '&random=' + Math.random());
                    } else {
                        $(".verifyimg").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
                    }
                });
            });



            $(function () {
                $("[data-role='getVerify']").click(function () {
                    var $this = $(this);
                    toast.showLoading();
                    var account = $this.parents('.tab-pane').find('[name="username"]').val();
                    var type = $this.parents('.tab-pane').find('[name="reg_type"]').val();
                    $.post("{:U('ucenter/verify/sendVerify')}", {account: account, type: type, action: 'member'}, function (res) {
                        if (res.status) {
                            DecTime.obj = $this
                            DecTime.time = "{: modC('SMS_RESEND','60','USERCONFIG')}";
                            $this.attr('disabled',true)
                            DecTime.dec_time();

                            toast.success(res.info);
                        }
                        else {
                            toast.error(res.info);
                        }
                        toast.hideLoading();
                    })
                })
                $('#reg_nav li a').click(function(){
                    $('.tab-pane').find('input').attr('disabled',true);
                    $('.tab-pane').eq($("#reg_nav li a").index(this)).find('input').attr('disabled',false);
                })
                $("[type='submit']").click(function () {
                    $(this).parents('form').submit();
                })

                 $('[href="#{$type}_reg"]').click()


            })
        }



        var DecTime = {
            obj:0,
            time:0,
            dec_time : function(){
                if(this.time > 0){
                    this.obj.text(this.time--+'S')
                    setTimeout("DecTime.dec_time()",1000)
                }else{
                    this.obj.text("{:L('_PHONE_VERIFY_')}")
                    this.obj.attr('disabled',false)
                }

            }
        }

    </script>
    <link href="__CORE_CSS__/form_check.css" rel="stylesheet" type="text/css">
    <script src='__CORE_JS__/form_check.js'></script>
    <script>
        // 验证密码长度
        $(function(){
            $('#inputPassword').after('<div class=" show_info" ></div>');
            $('#inputPassword').blur(function(){

                var obj =$('#inputPassword');
                var str =  obj.val().replace(/\s+/g, "");
                var html = '';
                if (str.length == 0) {
                    html = '<div class="send red"><div class="arrow"></div>'+"{:L('_EMPTY_CANNOT_')}"+'</div>';
                } else {
                    if (typeof (obj.attr('check-length')) != 'undefined') {
                        var strs = new Array(); //定义一数组
                        strs = obj.attr('check-length').split(","); //字符分割
                        if (strs[1]) {
                            if (strs[1] < str.length || str.length < strs[0]) {
                                html = '<div class="send red"><div class="arrow"></div>'+"{:L('_LENGTH_ILLEGAL_')}"+'</div>';
                            }
                        }
                        else {
                            if (strs[0] < str.length) {
                                html = '<div class="send red"><div class="arrow"></div>'+"{:L('_LENGTH_ILLEGAL_')}"+'</div>';
                            }
                        }
                    }
                    obj.parent().find('.show_info').html(html);
                }
            })
        })
    </script>
</block>
